<?php

//session.phpでログイン判断
require_once("session.php");
require_once("lib/myUtil.php");
include("./config/config.inc.php");
$cid = $_GET["cid"];

require("./libs/Smarty.class.php");
$smarty = new Smarty;

//↓↓↓↓↓セッションIDを取得する部分↓↓↓↓↓
$_SESSION["submit_id"] = session_id();//←セッションIDを取得する関数
//↑

dbChoice();
//クエリを送信する
if($cid != ""){
    $sql = "SELECT * FROM comment WHERE category_id = '".$cid."' ORDER BY id DESC";
}else{
    $sql = "SELECT * FROM comment ORDER BY created_at DESC";
}
$result =mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
    $sql = "SELECT * FROM reply WHERE comment_id = '"
           .$row["id"]."'ORDER BY created_at DESC";
    $result_reply = mysql_query($sql);
    while ($row_reply =mysql_fetch_array($result_reply)) {
        $row["reply"][] = $row_reply;
    }

    $rows[] = $row;
}

$smarty->assign("rows",$rows);
$smarty->assign("categorys",$categorys);
$article = $smarty->fetch("article.tpl");
$smarty->assign("article",$article);

$smarty->display("index.tpl");

?>
